package com.yaowk.service.mall.clothing.entity;

import com.yaowk.service.common.BaseEntity;
import com.yaowk.service.file.entity.TSource;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Set;

/**
 * 商品
 */
@Getter
@Setter
@ToString
@Entity
@DynamicInsert
@DynamicUpdate
public class CmGoods extends BaseEntity<Integer> {

    @Column(nullable = false)
    private String name; // 商品名称
    private String keyword; // 关键字
    @Column(nullable = false)
    @ColumnDefault("0")
    private Byte sort; // 排序
    @Column(nullable = false)
    private BigDecimal price; // 价格
    @Column(nullable = false)
    private BigDecimal originalPrice; // 原价
    @Column(nullable = false)
    private BigDecimal costPrice; // 成本
    private Byte status; // 商品状态
    private BigDecimal shipPrice; // 运费
    private Integer autoReceive; // 自动收货时间
    @Column(columnDefinition = "text")
    private String detail;
    @ColumnDefault("0")
    private Integer sellNumber; // 售出件数

    @ManyToOne
    private TSource smallImage; // 略缩图
    @OneToMany
    private Set<CmSpecification> specification; // 商品规格
    @ManyToOne
    private CmGoodsClass goodsClass; // 商品分类
    @ManyToMany
    @JoinTable(name = "CmGoodsImage", joinColumns = {@JoinColumn(name = "goodsId")}, inverseJoinColumns = {@JoinColumn(name = "imageId")})
    private Set<TSource> goodsImages; // 商品图片
}
